
require(["core", "hash_routie", "coAjax", "queryString", "href", "jQuery", "/js/mb/_build.js"], function(jSouper, hash_routie, coAjax, QueryString, href, jQuery) {

	coAjax.post(appConfig.recordVisitorInfo, {
		bus_id: "www"
	}, function(result) {
		console.log("访客信息已经记录：", result.result);
	});
	coAjax.get(appConfig.open.www_visitor_num, function(result) {
		App.set("$Cache.www_visitor_num", result.result);
	});
	/*
	 * 改变菜单
	 */
	var queryString = new QueryString();
	if (queryString.get("mid")) {//如果有邀请开站的，直接跳转到开站
		App.set('navdata', 3);
	}else{
		App.set('navdata', '0');
	}
	App.set('$Event.changeNav', function() {
		App.set('navdata', $(this).attr('data'));
	});


	/*
	 * 显示时钟
	 */
	(function _setTime() {
		// App.set("$Cache.extendInfo.time", (new Date).toLocaleString());
		App.set("$Cache.extendInfo.time", +new Date);
		setTimeout(_setTime, 1000)
	}())

	// case
	coAjax.get(appConfigPub.open.case_list, {
		num: 4
	}, function(result) {
		App.set("$Cache.dotnar_case.list", result.result);
	});

	//百度地图
	var ak_key = "E1c20826ad9c3bccec028cfb9ee17feb";
	var doc_write = document.write;
	var doc_s_write = function(HTML) {
		var dom = $("<div>" + HTML + "</div>");
		dom.find("script[src]").each(function(i, scriptNode) {
			scriptNode.src && require([scriptNode.src]);
			scriptNode.removeAttribute("src");
			// dom.remove(scriptNode);
		});
		dom.appendTo(document.body);
	}
	document.write = doc_s_write;
	require(["http://api.map.baidu.com/api?v=2.0&ak=" + ak_key], function(scriptText) {
		document.write = doc_write;
		var _BMap_ti = setInterval(function() {
			if (window.BMap) {
				clearInterval(_BMap_ti);
				init_map();
			}
		})
	});

	// 百度地图API功能
	function init_map() {
		var map = new BMap.Map("dituContent"); // 创建Map实例
		// map.centerAndZoom(new BMap.Point(X, Y), 9);     // 初始化地图,设置中心点坐标和地图级别，数字越大，缩放比例越大
		map.addControl(new BMap.NavigationControl()); // 添加平移缩放控件
		map.addControl(new BMap.ScaleControl()); // 添加比例尺控件
		// map.addControl(new BMap.OverviewMapControl());              //添加缩略地图控件
		map.enableScrollWheelZoom(); //启用滚轮放大缩小
		// map.addControl(new BMap.MapTypeControl());          //添加地图类型控件
		// map.setCurrentCity("福州");          // 设置地图显示的城市 此项是必须设置的

		var local = new BMap.LocalSearch(map, {
			renderOptions: {
				map: map
			}
		});

		local.search("深圳龙岗区锦龙大道2号精华中工业园1栋5楼");
		// local.search("上海市黄浦区汉口路201号");
	};
	// 发送消息
	App.set("$Event.message.add_message", function(e) {
		coAjax.post(appConfigPub.open.add_message, {
			title: App.get("$Cache.message.title"),
			name: App.get("$Cache.message.name"),
			email: App.get("$Cache.message.email"),
			content: App.get("$Cache.message.content")
		}, function(result) {
			alert("success", "管理员已经收到您的留言，具体回复将会以邮件形式发送给您。");
			//清空缓存
			App.set("$Cache.message", {});
		});
	});

	App.set('$Checked', '1');
	// choseType
	App.set("$Event.checkType", function(e, vm) {
		App.set("$Checked", $(this).attr('data'));
	})
	App.set("$Event.cancelPay", function() {
		App.set("IsPay", false);
	});
});